<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class NewsController extends HomeController {   

	//公司动态首页
    public function index($p = 1){
        $Document = D('Document');
		
        $map['category_id'] =   40;
        $map['status']      =   1;
        $n = 2;
        if($_GET['order'] == 'hot'){
            $order = '`view` DESC';
        }else{
           $order = '`create_time` DESC'; 
        }  
        $count = $Document->listCount($map);
        $Page = new \COM\NewsPage($count,$n);
        $lists = $Document->page($p, $n)->homelists($map,$order);
        $list = $Document->page(1,6)->homelists($map,'`view` DESC');
		//print_r($lists);
        $this->assign('lists',$lists);//列表
        $this->assign('list',$list);//排行
        $this->assign('page', $Page->newsshow());
        // $this->assign('page',D('Document')->page);//分页
        $this->meta_title='凡宇货运|公司动态';
        $this->display();
    }

    //公司动态首页
    public function main($id){
        $Document = D('Document');
        $map['category_id'] =   40;
        $map['status']      =   1;
        $lists = $Document->detail($id);
        $list = $Document->page(1,6)->homelists($map,'`view` DESC');
        $this->assign('list',$list);//排行        
        $this->assign('lists',$lists);//列表
        $this->meta_title='凡宇货运|公司动态';
        $this->display();
    }

}
